//
//  MYAFNetworkingTool.swift
//  MYWeiBo
//
//  Created by apple on 16/5/13.
//  Copyright © 2016年 YanMo. All rights reserved.
//

import UIKit
import AFNetworking
 /// 网络请求的类型枚举
enum requestmeMethod:String{
    case GET = "GET"
    case POST = "POST"
}

class MYAFNetworkingTool: NSObject {
    
    //单例
    static let shardInstance:MYAFNetworkingTool = MYAFNetworkingTool()
    //属性r
    private let AFManager : AFHTTPSessionManager = {
        let afn = AFHTTPSessionManager(baseURL:NSURL(string: "https://api.weibo.com/"))
        afn.responseSerializer.acceptableContentTypes?.insert("text/plain")
        return afn
    }()

    
    func request(Method:requestmeMethod,URLString: String, parameters: AnyObject?,success:((NSURLSessionDataTask, AnyObject?) -> Void)?,failure:((NSURLSessionDataTask?, NSError) -> Void)?){
    
        if Method == requestmeMethod.GET {
            AFManager.GET(URLString, parameters: parameters, progress: nil, success: success, failure: failure)

        }else
        {
            AFManager.POST(URLString, parameters: parameters, progress: nil, success: success, failure: failure)
        
            
        }
    }

}
